<template>
  <view class="mh-ql-success">
    <view class="mh-ql-succ">
      <view class="mh-ql-succ-icon"></view>
      <view class="mh-ql-succ-ct">
        <view v-if="!type" class="mh-ql-succ-txt">修改成功</view>
        <view v-if="!type" class="mh-ql-succ-txt">感谢您的配合</view>
        <view v-if="type" class="mh-ql-succ-txt">已填写</view>
        <view v-if="type == 'dataIsi'" class="mh-ql-succ-txt" >失眠严重指数（ISI）</view>
        <view v-if="type == 'dataGad7'" class="mh-ql-succ-txt" >焦虑问卷</view>
        <view v-if="type == 'dataPhq9'" class="mh-ql-succ-txt" >心理健康问卷</view>
      </view>
      <!-- <view class='mh-ql-score'>
        <view class='mh-ql-score-list' v-for='item in score' :key='item.title'>
          <view class='mh-ql-score-list-title'>{{item.title}}</view>
          <view class='mh-ql-score-list-row'>
            <view>{{item.value}}</view>
            <view :class="{ remind : item.result =='未评估' }">{{item.result}}</view>
          </view>
        </view>
      </view> -->
    </view>
    <view class="complate">
      <!--  <view v-if="type && !allFinish" class="elseQuestion">其他心理评估问卷</view>
      <view class="nav-list" v-if="type">
        <view 
          v-for="(item, index) in reportList"
          :key="item.type"
          @click="startBtn(item.type)">
          <view v-if="!item.isComplete" class="nav-list-item self-report-list-item">
            <view class="nav-list-item-img">
              <image
                class="nav-list-item-img-show"
                :src="item.icon"
                mode="widthFix"
              ></image>
            </view>
            <view class="nav-list-item-title">{{ item.title }}</view>
            <view class="nav-list-item-success" v-if='item.isComplete'>已填写</view>
            <view class="nav-list-item-success uncomplate" v-if='!item.isComplete'>未填写</view>
          </view>
        </view>
      </view> -->
    <view class="mh-ql-succ-btn" :class="{ hasType: type}" @click="goBack()" >返 回</view>
    </view> 
  </view>
</template>

<script>
export default {
  data() {
    return{
      type:'',
      //自主填报菜单
      reportList: [
        {
          icon: "https://szgd-dev.tgovcloud.com/public/images/anxious.png",
          title: "焦虑问卷",
          type: "dataGad7",
          isComplete: uni.getStorageSync('dataGad7')
        },
        {
          icon: "https://szgd-dev.tgovcloud.com/public/images/psychology.png",
          title: "心理健康问卷",
          type: "dataPhq9",
          isComplete: uni.getStorageSync('dataPhq9')
        },
        {
          icon: "https://szgd-dev.tgovcloud.com/public/images/insomnia.png",
          title: "失眠严重指数",
          type: "dataIsi",
          isComplete: uni.getStorageSync('dataIsi')
        },
      ],
      score:[],
    }
  },
  computed:{
    allFinish(){
      let dataIsi = uni.getStorageSync('dataIsi');
      let dataPhq9 = uni.getStorageSync('dataPhq9');
      let dataGad7 = uni.getStorageSync('dataGad7');
      return dataIsi && dataIsi.length && dataPhq9 && dataPhq9.length && dataGad7 && dataGad7.length;
    }
  },
  onLoad(option){
    this.type = option.type;
    //失眠严重指数：dataIsi
    //心理健康问卷：dataPhq9
    //焦虑问卷：dataGad7
    console.log('this.type:',this.type);
    this.score=[{
      title:'ISI得分',
      value:option.scoreIsi || '',
      result:option.resultIsi || ''
    },{
      title:'PHQ-9得分',
      value: option.scorePhq9 || '',
      result:option.resultPhq9 || ''
    },{
      title:'GAD得分',
      value:option.scoreGad7 || '',
      result:option.resultGad7 || ''
    }]
  },
  methods: {
    close(){
      // plus.runtime.quit();
    },
    goBack() {
      // uni.reLaunch({
      //   url:'../index/index'
      // })
      // uni.redirectTo({
      //   url: `./index?type=${this.type}`
      // })
      uni.navigateBack({
        delta: 2
      });
    },
    startBtn(type){
      uni.reLaunch({
        url:`/packageIsolate/pages/mentalHealth/questionnaire?type=${type}`
      })
    },
  },
};
</script>

<style scoped lang="scss">
.mh-ql-success {
  min-height: 100vh;
  background-color: #f2f2f2;
  box-sizing: border-box;
  .mh-ql-succ {
    padding-top: 104rpx;
    background-color: #fff;
  }
  .mh-ql-score{
    padding:0 32rpx;
    .mh-ql-score-list{
      border-bottom:1rpx solid #E5E5E5;
      .mh-ql-score-list-title{
        font-size:30rpx;
        color:#999;
        margin-bottom:22rpx;
        font-weight:500;
      }
      .mh-ql-score-list-row{
        display:flex;
        justify-content: space-between;
        margin-bottom:26rpx;
        &>view:first-child{
          color:#000;
          font-size:34rpx;
          font-weight:500;
        }
        &>view:last-child{
          font-size:34rpx;
          color:#2C9AF1;
          font-weight:500;
        }
        .remind{
          color: red !important;
        }
      }
    }
  }
  .mh-ql-succ-icon {
    background-repeat: no-repeat;
    background-image: url(https://szgd-dev.tgovcloud.com/public/images/mentalHealth/suc.png);
    background-position: center center;
    background-size: 176rpx auto;
    height: 338rpx;
  }
  .mh-ql-succ-ct {
    padding-bottom: 80rpx;
    .mh-ql-succ-txt {
      font-size: 40rpx;
      font-family: PingFang SC;
      line-height: 60rpx;
      color: #333333;
      text-align: center;
    }
  }
  .mh-ql-succ-btn {
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    height: 94rpx;
    background: #2c9af1;
    // border: 1rpx solid #2c9af1;
    border-radius: 16rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    margin-top: 50rpx;
    font-size:30rpx;
  }
  .hasType{
    margin-top: 30rpx;
  }
}
.complate{
  padding: 0 32rpx 100rpx 32rpx;
  box-sizing: border-box;
  .elseQuestion{
    font-size: 32rpx;
    height: 100rpx;
    line-height: 100rpx;
    font-family: PingFang SC;
    color: #333333;
  }
}
.nav-list {
  // padding-top: 40rpx;
  box-sizing: border-box;
  display: flex;
  flex-direction: column-reverse;
  &-item {
    // background: url(https://szgd-dev.tgovcloud.com/public/images/bg.png);
    // background-size: 100% 100%;
    // background-repeat: no-repeat;
    width: 100%;
    background: #fff;
    border-top:1rpx solid rgba($color:#2c9af1, $alpha:.2);
    box-shadow:0px 1px 10px rgba($color: #E5E5E5, $alpha: .8);
    // height: 300rpx;
    border-radius: 16rpx;
    margin-bottom: 32rpx;
    padding: 40rpx 30rpx 40rpx 40rpx;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    &-title {
      flex: 2;
      font-size:36rpx;
    }
    &-img {
      margin-right: 20rpx;
      &-show {
        width: 110rpx;
        height: 110rpx;
      }
    }
    &-arr {
      flex: 1;
      margin-right: 20rpx;
      text-align: right;
      &-btn {
        width: 120rpx;
        color: #fff;
        border: 1px solid #2c9af1;
        background-color: #2c9af1;
        border-radius: 16rpx;
        padding: 10rpx 40rpx;
        font-size: 34rpx;
        text-align: center;
        &-second{
          background-color: #fff;
          color: #2c9af1;
        }
      }
      &-show {
        width: 24rpx;
      }
    }
    &-success{
      width: 20rpx;
      height: 20rpx;
      background-image: url();
      background-size: 100% 100%;
      background-repeat: no-repeat;
    }
  }
}
.nav-list-item-success{
  width: 90rpx;
  height: 40rpx;
  font-size: 28rpx;
  background-size: 38rpx 38rpx;
  background-position: bottom left;
  padding-left: 45rpx;
  text-align: right;
  // font-weight: 400;
}
.uncomplate{
  background-image: url("https://szgd-dev.tgovcloud.com/public/images/mentalHealth/uncomplate.png");
}
</style>
